package com.xbongbong.saas.model;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.aiassistant.domain.entity.AiProductionOrderEntity;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.domain.entity.UpdateDataEntity;
import com.xbongbong.pro.formdata.pojo.dto.SaasAnalysisDataDTO;
import com.xbongbong.saas.domain.entity.ProductionOrderProductEntity;
import com.xbongbong.saas.domain.entity.ext.ProductionOrderEntityExt;
import com.xbongbong.saas.enums.UpdateDataTypeEnum;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * @author feng.zheng
 * @version v1.0
 * @date 2019/1/25 10:18
 * @since v1.0
 */

public interface ProductionOrderModel extends IModel<ProductionOrderEntityExt> {
    /**
     * 保存实体
     *
     * @param productionOrderEntity 生产单实体
     * @return java.lang.Integer
     * @throws XbbException 数据库异常
     * @author feng.zheng
     * @date 2019/2/14 16:42
     */
    Integer save(ProductionOrderEntityExt productionOrderEntity) throws XbbException;

    /**
     * 获取单个实体
     *
     * @param key    id主键
     * @param corpid 公司id
     * @return com.xbongbong.saas.domain.entity.ProductionOrderEntityExt
     * @author feng.zheng
     * @date 2019/2/14 16:43
     */
    ProductionOrderEntityExt getByKey(Long key, String corpid);
    /**
     * 获取符合查询条件的记录
     *
     * @param param 查询条件
     * @return 符合查询条件的记录
     */
    @Override
    List findEntitys(Map<String, Object> param);

    /**
     * 批量更新
     * @param list
     * @param corpid
     * @return
     * @exception XbbException
     */
    Integer updateBatch(List<UpdateDataEntity> list, String corpid) throws XbbException;

    Integer updateBatchImmediately(List<UpdateDataEntity> list, String corpid) throws XbbException;

    /**
     * 批量删除
     * @author 吴峰
     * @date 2019/3/5 21:46
     * @param productionOrderIdIn
     * @param corpid
     * @return java.lang.Integer
     * @throws XbbException 业务异常
     */
    Integer deleteBatch(List<Long> productionOrderIdIn, String corpid) throws XbbException;

    /**
     * 单个删除
     * @param id
     * @param corpid
     * @return
     * @throws XbbException
     */
    Integer deleteByKey(Long id,String corpid) throws XbbException;

    /**
     * 获取智能助手需要的生产单数据
     *
     * @param corpid 公司id
     * @param idIn 数据ids
     * @return
     * @throws
     * @author hongxiao
     * @date: 2020-02-24 17:00
     * @since v4.13.0
     * @version v4.13.0
     */
    List<AiProductionOrderEntity> getProductionOrderList4Ai(String corpid, List<Long> idIn);

    List<String> getCorpidList();

    /**
     * 批量更新
     * @param updateList
     * @param corpid 公司id
     * @param refreshPolicy
     * @return
     * @throws XbbException
     */
    Integer updateBatch(List<UpdateDataEntity> updateList, String corpid, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    @Override
    List findEntitysWithoutSub(Map<String, Object> param);

    /**
     * 编辑时格式化解释
     *
     * @param formatExplainDTO 入参
     * @throws XbbException 异常
     * @author long.rao
     * @date 2019-02-13 20:53
     */
    void formatUpdateExplain(FormatExplainDTO formatExplainDTO) throws XbbException;

    /**
     * 编辑时将获取数据格式化
     *
     * @param formDataUpdateGetDTO saas编辑数据
     * @param result               要返回的jsonobject
     * @throws XbbException 业务异常
     * @author feng.zheng
     * @date 2019/1/22 15:28
     */
    void formatData(SaasAnalysisDataDTO formDataUpdateGetDTO, JSONObject result) throws XbbException;

    JSONObject formatSingleProduct(ProductionOrderProductEntity productionOrderProductEntity);

    void formatProduct4Show2(Long dataId, String corpid, JSONObject data, UpdateDataTypeEnum updateDataTypeEnum) throws XbbException;

    Integer updateTime(Long id,String corpid) throws XbbException ;
}
